package com.mytime.util;

public class Time {
	
	private int time;
	private int hour;
	private int minute;
	
	public Time(String time) {
		//TODO: check String format
		String[] timeArray = time.split(":");
		int hour = Integer.parseInt(timeArray[0]) * 60;
		int minute = Integer.parseInt(timeArray[1]);		
		
		this.time = hour + minute;
		this.hour = this.time / 60;
		this.minute = this.time % 60;
	}
	
	public Time(int time) {
		if (time < 0)
			return;
		
		this.time = time;
		this.hour = time / 60;
		this.minute = time % 60;
	}
	
	public void setTime(String time) {
		String[] timeArray = time.split(":");
		int hour = Integer.parseInt(timeArray[0]) * 60;
		int minute = Integer.parseInt(timeArray[1]);		
		this.time = hour + minute;		
	}
	
	public int getTime() {
		return this.time;
	}
	
	public String toString() {
		return this.hour + ":" + this.minute;
	}
}
